import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const login = import("@/views/login");
const dashbord = import("@/views/dashbord");

const routes = [
  {
    name: "Login",
    path: "/login",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // 路由懒加载
    component: () => login,
  },
  {
    name: "main",
    path: "/",
    component: () => import("@/layout"),
    redirect: "/dashbord",
    children: [
      {
        name: "Dashbord",
        path: "/dashbord",
        component: () => dashbord,
      },
    ],
  },
  {
    name: "404",
    path: "*",
    component: () => import("@/views/404"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
